package com.fitnessrocks.sweattimer.data;

import android.content.Context;

import com.fitnessrocks.sweattimer.R;

/**
 * Abstract class specifying workout.
 *
 * Some naming convention:
 *     Workout  = Total session the timer is timing.
 *     Sequence = A part of the workout starting with optional lead-in time,
 *                one or more work times, and a rest time.
 *     Interval = Individual part of the workout, such as lead-in, rest, or
 *                actual work.
 *
 * @author andyced
 */
public abstract class AbstractTimer {
	enum IntervalType {
		LEAD_IN,
		OTHER,
		REST,
		WORK
	}

	protected final Context mContext;
	protected final String mName;

	protected AbstractTimer(Context context, String name) {
	    mContext = context;
		mName = name;
	}

	public abstract long getIntervalDuration(int intervalIndex);
    public abstract int getIntervalIndex(long timeInMillis);
	public String getIntervalName(int intervalIndex) {
        switch (getIntervalType(intervalIndex)) {
        case LEAD_IN:
            return mContext.getString(R.string.generic_timer_interval_name_lead_in);
        case REST:
            return mContext.getString(R.string.generic_timer_interval_name_rest);
        case WORK:
            return mContext.getString(R.string.generic_timer_interval_name_work);
        default:
            return mContext.getString(R.string.generic_timer_interval_name_other);
        }
    }
	public abstract long getIntervalTimeLapsed(long timeInMillis);
	public abstract long getIntervalTimeLeft(long timeInMillis);
    public abstract IntervalType getIntervalType(int intervalIndex);

	public String getName() { return mName; }

	public abstract int getSessionIndex(long timeInMillis);
	public abstract String getSessionName(int sessionIndex);
	public abstract long getSessionTimeLapsed(long timeInMillis);
	public abstract long getSessionTimeLeft(long timeInMillis);

	public abstract long getTotalDuration();
	public abstract int getTotalIntervals();
    public abstract int getTotalIntervalsLapsed(int intervalIndex);
    public abstract int getTotalIntervalsLeft(int intervalIndex);
    public abstract int getTotalSessions();
    public abstract int getTotalSessionsLapsed(int sessionIndex);
    public abstract int getTotalSessionsLeft(int sessionIndex);
    public abstract long getTotalTimeLapsed(long timeInMillis);
    public abstract long getTotalTimeLeft(long timeInMillis);
}
